import { Controller, Get, Post, Body, Param, Patch, Delete, Query, Request, Headers, Inject } from '@nestjs/common';
import { UserService } from './user.service'
@Controller('user')
export class UserController {

    // constructor(private readonly userService: UserService) { }
    // 通过useClass方式注入的需要通过inject('UserService')来注入
    constructor(@Inject('user') private readonly userService: UserService) { }

    // 
    @Get()
    getAllUsers(@Query('a') query) {
        debugger
        return this.userService.getAllUsers(query);
    }

    @Post('createUser')
    createUser(@Body() body) {
        console.log(' [ body ]-15', body)
        return this.userService.createUser(body);
    }


    @Post('updateUser')
    updateUser(@Request() req, @Headers() headers) {
        console.log(' [ body ]-16', req, headers)
        return this.userService.updateUser(req.body);
    }


    /**
     * /user/:id
     */
    @Get(':id')
    getUser(@Param('id') id) {
        return this.userService.getUser(id);
    }


}
